using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.Contracts;
using Beaker.OpenCube.CubeManager.Model.Framework;

namespace Beaker.OpenCube.CubeManager.Model.Entities
{
	/// <summary>
	/// A Set of Roles assigned to a user for specific machine, server or system
	/// </summary>
	public class RoleSet
		: Entity
	{
		private readonly EntitySet<Role, RoleSet> _roles;

		public RoleSet( User user )
			: this()
		{
			Contract.Requires<ArgumentNullException>( user != null );

			User = user;
		}

		public RoleSet()
		{
			_roles = new EntitySet<Role, RoleSet>( this, role => role.RoleSet );
		}

		/// <summary>
		/// Gets the user for who this role-set is
		/// </summary>
		[Required]
		public User User { get; internal set; }

		/// <summary>
		/// Gets the set of roles this user has assigned
		/// </summary>
		public ISet<Role> Roles { get { return _roles; } } 
	}
}